package com.study.studyfive.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @date 2023/9/20
 * @description 消费者
 */
@Component
// 监听也可以放下面，写多个监听
// @RabbitListener(queues = "TestDirectQueue")//监听的队列名称 TestDirectQueue
public class DirectReceiverConsumer {

  /*  @RabbitListener(queues = "TestDirectQueue")// 监听的队列名称 TestDirectQueue
    @RabbitHandler
    public void process1_1(String msg) {
        System.out.println("DirectReceiverConsumer：1_1消费者收到(TestDirectQueue)消息  : " + msg);
        Map map = JSONObject.parseObject(msg, Map.class);
        System.out.println(msg);;
        System.out.println(map);
    }

    @RabbitListener(queues = "TestDirectQueue")// 监听的队列名称 TestDirectQueue
    @RabbitHandler
    public void process1_2(String msg) {
        System.out.println("DirectReceiverConsumer：1_2消费者收到(TestDirectQueue)消息  : " + msg);
    }*/

    @RabbitListener(queues = "TestDirectQueue2")// 监听的队列名称 TestDirectQueue2
    @RabbitHandler
    public void process2(String msg) {
        System.out.println("DirectReceiverConsumer消费者收到(TestDirectQueue2)消息  : " + msg);
    }
}

